package com.jiaai.cloud.wx.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jiaai.cloud.wx.entity.TAdmin;
import com.jiaai.cloud.wx.mapper.TAdminMapper;
import com.jiaai.cloud.wx.mapper.TEmpMapper;
import com.jiaai.cloud.wx.mapper.TGroupMapper;
import com.jiaai.cloud.wx.mapper.TPayMapper;
import com.jiaai.cloud.wx.service.ITAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 佳爱网络科技
 * @since 2017-08-28
 */
@Service
public class TAdminServiceImpl extends ServiceImpl<TAdminMapper, TAdmin> implements ITAdminService {

    @Autowired
    private TPayMapper tPayMapper;
    @Autowired
    TGroupMapper tGroupMapper;
    @Autowired
    TEmpMapper tEmpMapper;

    @Override
    @Transactional
    public void payBatch(int[] ids) {
        for(int id : ids){
           tPayMapper.updateStatus(id);
        }
    }

    @Override
    @Transactional
    public void deleteGroupEmp(Integer id) {
        List<String> empids = tEmpMapper.selectEmpids(id);
        for (String empid : empids){
            tPayMapper.logicalDelete(empid);
        }
        tEmpMapper.logicalDelete(id);
        tGroupMapper.deleteById(id);
    }
}
